
<jsp:directive.page session="true" />

<html>
<body>

<%
if (session.getAttribute("message") != null) {
%><p><strong><%=(String)session.getAttribute("message")%></strong></p><%
	session.removeAttribute("message");
}
%>

<%
		if (request.getParameter("logout") != null) {
		session.removeAttribute("openid");
		session.removeAttribute("openid-claimed");
%> <p><strong>You have been logged out.</strong></p> <%
 }
 %>

<%
	// take care of cookies

	Cookie cookies[] = request.getCookies();
	Cookie myCookie = null;
	
	if (cookies != null) {
		for (int i = 0; i < cookies.length; i++) {
			if (cookies[i].getName().equals("claimedOpenIDName")) {
		myCookie = cookies[i];
		break;
			}
		}
	}
	String claimedOpenIDName = "";
	if ( myCookie != null ) 
		claimedOpenIDName = myCookie.getValue();
		
	
%>

<h2>Login using OpenID</h2>

The DAS registration server uses <a href="http://openid.net">OpenID</a>
for the user login. OpenID is a free and decentralized single sign-on system.
<br/>
<br/>
<%
if (session.getAttribute("openid") == null) {
%>

<form method="POST" action="consumer_redirect.jsp">
<table>
<tr><td><strong>OpenID:</strong> </td>
<td><input class="openid" type="text" name="openid" size="40" value="<%=claimedOpenIDName %>"/> <a href="help_openid.jsp">help</a></td></tr>

<tr><td>remember me:</td>
<td><input type="checkbox" name="remember" VALUE="1"<% 

	if ( ! ( claimedOpenIDName.equals(""))) {
		out.print("checked");
	}

%>> </td></tr>
<tr><td >&nbsp;</td><td align="right"><input type="submit" value="login"/></td></tr>
</table>
</form>

Please provide your OpenID. <br/>
Get one for free from <a href="http://www.myopenid.com">http://www.myopenid.com</a>.


<%
} else {
	
	boolean isAdmin = false;
	String openid = (String)session.getAttribute("openid");
%>
<ul>
<li>You are logged in as <% 
if ( isAdmin ) {
	%><strong>admin user</strong> <% 
}%><b><%= openid %></b></li>
<li><a href="loginSettings.jsp">view</a> your account settings</li>
</ul>
<br/><br/>
[ <a href="?logout=true">Log out</a> ]
<%
}
%>


<p>You can lean more about OpenID at:</p>
<ul>
	<li><a href="http://openid.net">http://openid.net</a></li>
	<li><a href="http://en.wikipedia.org/wiki/OpenID">http://en.wikipedia.org/wiki/OpenID</a></li>
</ul>




</div>

</body>
</html>
